package sk.xorty.si;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import sk.xorty.oxm.Inventory;

import java.math.BigInteger;
import java.util.Arrays;

@Component
public class InventoryMapper implements Mapper {

    @Override
    public Object map(String[] content) {
        System.out.println("======== MAPPER INVOKED ========");
        System.out.println("\t=> Mapping this content to Inventory: " + Arrays.toString(content));

        Inventory inventory = new Inventory();
        inventory.setId(content[0]);
        inventory.setBranch(content[1]);
        inventory.setKeyword(content[2]);
        inventory.setProduct(content[3]);
        inventory.setBeginning(BigInteger.valueOf(Long.valueOf(content[4])));
        inventory.setEnding(BigInteger.valueOf(Long.valueOf(content[5])));

        return inventory;
    }
}
